#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# Licensed Materials - Property of tenxcloud.com
# (C) Copyright 2020 TenxCloud. All Rights Reserved.
# 2020-06-08 @author lizhen

import tensorflow as tf

from pathlib import Path
import os
import json

parent = Path(os.path.dirname(os.path.abspath(__file__))).parent
model_set_dir = os.path.join(parent, 'modelsets')
mnist_npz = os.path.join(parent, 'datasets', 'mnist.npz')

mnist = tf.keras.datasets.mnist

(x_train, y_train), (x_test, y_test) = mnist.load_data(path=mnist_npz)
x_train, x_test = x_train / 255.0, x_test / 255.0

x_test = x_test.reshape(x_test.shape[0], 28, 28, 1)

data = json.dumps({'instances': x_test[0:1].tolist()})

print(data)
